package com.company.project.controller;

import com.company.project.common.utils.DataResult;
import com.company.project.util.TransactionHandler;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RequestMapping(value = "/Transaction")
@Controller
public class TransactionConroller {

    @Autowired
    private TransactionHandler transactionHandler;

    // 导入
    @ApiOperation("上传")
    @RequestMapping(value = "/importData", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public DataResult importData(@RequestPart(value = "file") MultipartFile file) {
//        log.debug("importData.............");
        System.out.println("[TransactionConroller]");
        return transactionHandler.importExcel(file);
    }

}